package com.blacktry.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.blacktry.entity.model.ExamManage;
import com.blacktry.entity.model.OperationLog;
import com.blacktry.entity.model.request.LogRequest;
import com.blacktry.mapper.OperationLogMapper;
import com.blacktry.service.OperationLogService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author blackTry
 * @since 2022-01-25
 */
@Service
public class OperationLogServiceImpl extends ServiceImpl<OperationLogMapper, OperationLog> implements OperationLogService {

    @Override
    public Page<OperationLog> selectOperationLog(LogRequest logRequest, Page<OperationLog> logPage) {
        LambdaQueryWrapper<OperationLog> wrapper = new LambdaQueryWrapper<>();
        if(logRequest.getUsername()!=null){
            wrapper.like(OperationLog::getOperUserName,logRequest.getUsername());
        }
        if(logRequest.getType()!=null){
            wrapper.eq(OperationLog::getOperType,logRequest.getType());
        }
        if(logRequest.getBeginTime()!=null){
            wrapper.ge(OperationLog::getOperCreateTime,logRequest.getBeginTime());
        }
        if(logRequest.getEndTime()!=null){
            wrapper.le(OperationLog::getOperCreateTime,logRequest.getEndTime());
        }
        return this.baseMapper.selectPage(logPage,wrapper);
    }
}
